﻿@model GameCode.Models.Admin.GameCodeListModel
@{
    ViewBag.Title = "游戏特权 - 可用特权码";
    Model.Caption = "可用特权码";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<script type="text/javascript">
    function selectAll() {
        $(".code").attr("checked", "checked");
    }
    function deleteCode() {
        var str = "";

        $(".code").each(function () {
                if (str == "") {
                    str += $(this).attr("id");
                }
                else {
                    str += "!" + $(this).attr("id");
                }
            
        });
        $(".SelectCodeList").val(str);
    }
</script>
@using (Html.BeginForm(new { act = "submit" }))
{
    @Html.HiddenFor(m => m.ID)
    @Html.HiddenFor(m => m.SelectCodeList, new { @class = "SelectCodeList"})
    <div class="ui-body ui-body-a">
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.GameName)
            @Html.DisplayFor(m => m.GameName, new Dict() { "data-mini:true" })
        </div>
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.ProjectName)
            @Html.DisplayFor(m => m.ProjectName, new Dict() { "data-mini:true" })
        </div>
        <div data-role="fieldcontain">
            @Html.LabelFor(m => m.Count)
            @Html.DisplayFor(m => m.Count, new Dict() { "data-mini:true" })
        </div>
        <div data-role="fieldcontain">
        <input type="button" value="清除所有未用特权码"  data-inline="true" data-mini="true" onclick="window.location.href='/Admin/ClearCode?id=@Model.ID'"   />
        <input type="submit" value="清除这页的特权码"  data-inline="true" data-mini="true" onclick="deleteCode()"   />
        </div>
    </div>
    
      
    var grid = new WebGrid(source: Model.List, rowsPerPage: 300);
    @grid.GetHtml(
        htmlAttributes: new { cellpadding = "0", cellspacing = "0" },
        headerStyle: "ui-li ui-li-divider ui-btn ui-bar-a ui-btn-hover-undefined ui-btn-up-undefined",
    columns: grid.Columns
        (
            //grid.Column(header："特权号",format: (item) => Html.Raw(string.Format(@"<label class='code'>{0}</label>",item.ID))),
            grid.Column(header: "特权号", format: (item) => Html.Raw(string.Format(@"<label class='code' id='{0}'>{1}</label>",item.ID,item.Code1))),
            grid.Column(header: "删除", format: (item) => Html.ActionLink("删除", "CodeDelete", new { id = item.Id }), canSort: false)
        )
    )
}